﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuantitativeInvestment.Bean;
using QuantitativeInvestment.Tools;

namespace QuantitativeInvestment.Factor
{
    class TrimaFactor:Factor
    {
        public TrimaFactor()
        {
            this.name = "递归移动平均指标";
            Parameter p = new Parameter("天数", 30);
            this.paraList.Add(p.name, p);
        }
        public override void addFactorValue(Stock stock)
        {
            int num=Int32.Parse(this.paraList["天数"].value.ToString());
            if (!stock.factors.ContainsKey(this.name + this.paraList["天数"].value.ToString()))
            {
                TaLib lib = new TaLib();
                double[] trimaValues = lib.getTrima(stock.factors["价格"], num); ;
                stock.factors.Add(this.name + this.paraList["天数"].value.ToString() + "递归移动平均指标", trimaValues);
            }
        }
    }
}
